Skip to content

Conversation

@janisz
Copy link
Collaborator

@janisz janisz commented Oct 21, 2025

The pdbminavailable check crashed with a panic when it encountered a PodDisruptionBudget that has spec.minAvailable defined but is missing the required spec.selector field.

The code attempted to access pdb.Spec.Selector.MatchLabels and pdb.Spec.Selector.MatchExpressions without checking if Selector was nil, causing a nil pointer dereference.

This fix adds a nil check for pdb.Spec.Selector before accessing its fields. If the selector is missing, the check now returns a clear diagnostic message with a link to Kubernetes documentation instead of panicking.

Also added a unit test TestPDBWithMinAvailableButNoSelector to verify the fix handles this edge case correctly.

Fixes #1041

🤖 Generated with Claude Code

The pdbminavailable check crashed with a panic when it encountered a
PodDisruptionBudget that has spec.minAvailable defined but is missing
the required spec.selector field.

The code attempted to access pdb.Spec.Selector.MatchLabels and
pdb.Spec.Selector.MatchExpressions without checking if Selector was nil,
causing a nil pointer dereference.

This fix adds a nil check for pdb.Spec.Selector before accessing its
fields. If the selector is missing, the check now returns a clear
diagnostic message with a link to Kubernetes documentation instead of
panicking.

Also added a unit test TestPDBWithMinAvailableButNoSelector to verify
the fix handles this edge case correctly.

Fixes #1041

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@janisz janisz requested a review from rhybrillou as a code owner October 21, 2025 09:29
@janisz janisz merged commit f8f1795 into main Oct 28, 2025
8 checks passed
@janisz janisz deleted the fix-pdbminavailable-nil-selector-1041 branch October 28, 2025 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] pdbminavailable check crashes on PDB with minAvailable and no selector

2 participants